"""
在线词典 ： 服务端数据处理
"""
import pymysql

class DictData:
    #连接数据库
    def __init__(self):
        self.kwargs={
            "host":"localhost",
            "port":3306,
            "user":"root",
            "password":"123456",
            "database":"dict",
            "charset":"utf8"
        }
        self.db=pymysql.connect(**self.kwargs)
        self.cur=self.db.cursor()

    #注册
    def register(self):
        pass

    #登录
    def login(self):
        pass

    #查单词
    def query_words(self):
        sql="select word,mean from words where word=%s;"
        word,mean=self.cur.fetchone(sql,[word])
        print(word,"：",mean)
        return word,mean
    #插入历史记录
    def insert_hist(self):
        pass

    #查看历史
    def history(self):
        pass

    #关闭
    def close(self):
        self.cur.close()
        self.db.close()

if __name__ == '__main__':
    dict=Dict()
    # dict.query_words()
    dict.close()
